package com.carpedil.demo.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.carpedil.demo.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/** @author Administrator */
@Repository
public interface UserMapper extends BaseMapper<User> {
  @Select(
      "select DISTINCT u.*,ud.*,r.*,p.* "
          + " FROM user_role ur "
          + " INNER JOIN users u on u.id = ur.fk_user_id "
          + " INNER JOIN roles r on r.pk_id = ur.fk_role_id "
          + " INNER JOIN user_detail ud on ud.user_detail_id = u.fk_user_detail_id "
          + " INNER JOIN role_permission rp on rp.fk_role_id = r.pk_id "
          + " INNER JOIN permissions p on p.permission_pk_id = rp.fk_permission_id "
          + " ${ew.customSqlSegment}")
  @ResultMap("com.carpedil.demo.dao.UserMapper.userMap")
  User login2(@Param(Constants.WRAPPER) Wrapper<User> wrapper);
}
